import Vue from 'vue'
import App from './App.vue'
import router from './router'

import 'lib-flexible/flexible'
import axios from 'axios'
import VueAxios from 'vue-axios'
Vue.use(VueAxios,axios)

Vue.config.productionTip = false

//引入vant组件
import {
  NavBar,
  Divider,
  Tabbar,
  TabbarItem,
  Swipe,
  SwipeItem,
  List,
  Cell,
  Icon,
  ShareSheet,
  Switch,
  Toast,
  CellGroup,    
  Form,
  Field,
  Popup,
  Button  

}from 'vant';


//注册vant组件
Vue.use(NavBar)
.use(Divider)
.use(Tabbar)
.use(TabbarItem)
.use(Swipe)
.use(SwipeItem)
.use(List)
.use( Cell)
.use(Icon )
.use(ShareSheet )
.use(Switch)
.use(Toast )
.use(CellGroup )
.use(Form )
.use(Field )
.use(Popup )
.use(Button )


//设置Vue原型属性
Vue.prototype.appkey = 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA=';

//axios拦截器，在发起请求之前执行
axios.interceptors.request.use(config => {

  //处理post请求参数, 进行参数序列化
  if (config.method == 'post') {

    //序列化post请求参数
    let paramsString = '';
    for (let key in config.data) {
      paramsString += `${key}=${config.data[key]}&`;
    }

    //重新赋值config.data
    config.data = paramsString.slice(0, -1);
  }
  //必须返回config
  return config;
})

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')

